package thread;

import java.util.Random;
import java.util.Vector;

public class RaceCar extends Thread{

	static Vector<RaceCar> cars = new Vector<>();
	
	public RaceCar(String name) {
		super(name);
	}

	@Override
	public void run() {
	    int speed = new Random().nextInt(101) + 200;
	    
		for(int i = 0 ; i <= 5000; i += speed) {
			System.out.println(this.getName() + ":" + i);
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			// 200 ~ 300
			speed = new Random().nextInt(101) + 200;
		}
		System.out.println(this.getName() + "到达");
		cars.add(this);
	}
}
